package com.freewater.springboot.demo.aop.simple;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;

@Aspect
public class SimpleAspect {

    @Pointcut("execution(* com.freewater.springboot.demo.aop.simple.SomeService.*(..))")
    private void allMethodOfSomeService() {
    }

    @Around("allMethodOfSomeService()")
    public Object someAdvice(ProceedingJoinPoint joinPoint) {
        try {
            System.out.println("some process before");
            final Object returnVal = joinPoint.proceed();
            System.out.println("some process after");
            return returnVal;
        } catch (Throwable e) {
            throw new RuntimeException(e);
        }
    }
}
